<template>
  <div class="container">
    <el-page-header @back="goBack" content="混凝土施工记录">
    </el-page-header>

    <!--    <div class="search">
    <span style="line-height: 100%">工程名称：</span>
    <el-input v-model="projectName" placeholder="请输入内容" style="width: 300px"/>
    <span style="line-height: 100%; margin-left: 10px">单位工程：</span>
    <el-input v-model="subprojectName" placeholder="请输入内容" style="width: 300px"/>
    <span style="line-height: 100%; margin-left: 10px">使用部位：</span>
    <el-input v-model="usePart" placeholder="请输入内容" style="width: 300px"/>
    <el-button type="primary" style="margin-left: 10px;margin-right: 10px" @click="search">搜索</el-button>
    <el-button type="warning" style="margin-left: 10px;margin-right: 10px;" @click="batchExport">批量导出</el-button>
  </div>

  <el-table :data="currentPageData" stripe style="width: 100%; margin-top: 15px"
            @selection-change="handleSelectionChange" row-key="taskId" ref="tableRef"
  >
    &lt;!&ndash; 第一列：多选框 &ndash;&gt;
    <el-table-column type="selection" width="55" :reserve-selection="true"/>
    &lt;!&ndash; 第二列：编号 &ndash;&gt;
    <el-table-column prop="projectName" label="项目名称" width="80" align="center"/>
    <el-table-column prop="subprojectName" label="单位工程名称" width="80" align="center"/>
    <el-table-column prop="usePart" label="使用部位" width="80" align="center"/>
    <el-table-column prop="level" label="强度等级" width="80" align="center"/>
    <el-table-column prop="yangHu" label="养护条件" width="80" align="center"/>
    <el-table-column prop="number" label="代表数量" width="80" align="center"/>
    <el-table-column prop="isFinished" label="是否采集完毕" width="80" align="center"/>


    &lt;!&ndash; 最后一列：操作按钮 &ndash;&gt;
    <el-table-column label="操作" align="center" width="200">
      <template slot-scope="scope">
        <el-button type="primary" @click="handlePreview(scope.row)">
          预览
        </el-button>
        <el-button type="warning" @click="handleExport(scope.row)">
          导出
        </el-button>
      </template>
    </el-table-column>
  </el-table>-->
    <div> 数据不全，暂时无法展示</div>

    <!-- 这是分页条  -->
    <el-pagination style="margin-top: 20px; text-align: center" :current-page="currentPage"
                   :page-sizes="[1, 10, 15, 20]" :page-size="pageSize" layout="prev, pager, next, jumper,->,sizes,total"
                   :total="totalData" @size-change="handleSizeChange" @current-change="handleCurrentChange"
    />

  </div>
</template>

<script>
import { searchFenbuCheck } from '@/api/statementManage/yanShou/statementManage'

export default {
  data() {
    return {
      projectName: '',
      subprojectName: '',
      usePart: '',     //这三个用来搜素表格项
      currentPageData: [],  //当前页面数据
      currentPage: 1,
      pageSize: 10,
      totalData: 0,   //这三个是分页条数据
      selectedRows: []  //选中行数组
    }
  },
  methods: {
    goBack() {
      this.$router.go(-1)
    },
    handleSizeChange(val) {
      this.pageSize = val
      console.log('表格容量更新为：' + val)
      this.search()
    },
    handleCurrentChange(val) {
      this.currentPage = val
      console.log('表格页数更新为：' + val)
      this.search()
    },
    handlePreview(row) {
      console.log('预览表格行数据为：' + JSON.stringify(row))

      const keyData = {
        subprojectId: row.subprojectId,
        fenbuId: row.fenbuId
      }

      console.log(JSON.stringify(keyData))

      sessionStorage.setItem('tempObj1', JSON.stringify(keyData))

    },
    handleExport(row) {
      console.log('导出表格行数据为：' + JSON.stringify(row))
    },
    handleSelectionChange(val) {
      this.selectedRows = val
      console.log('当前选中行为：' + JSON.stringify(val))
    },
    async search() {
      console.log('进行了搜索，参数为：' + this.projectName + '  ' + this.subprojectName + '  ' + this.fenbuName)
      const { result } = await searchFenbuCheck(this.projectName, this.subprojectName, this.fenbuName, this.currentPage, this.pageSize)
      console.log(JSON.stringify(result))
      this.currentPageData = result.list
      this.totalData = Number(result.total)
    },
    batchExport() {
      console.log('进行了批量导出')
    }
  },
  mounted() {
    this.search()
  }
}
</script>

<style scoped>
.container {
  margin-top: 10px;
  margin-left: 10px;
}

.search {
  text-align: right;
  margin-top: 20px;
}
</style>
